package com.unnamed.b.atv.view;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

/**
 * Created by Bogdan Melnychuk on 2/10/15.
 * edited by duantihi, 2016-02-16 13:42:37
 * 直接在根 LinearLayout上加 子view，减少一半的 层级
 * 解决层级过多导致 stack over flow 问题
 */
public class TreeNodeWrapperView extends LinearLayout {
    private LinearLayout nodeItemsContainer;
    private ViewGroup nodeContainer;
    private final int containerStyle;

    public TreeNodeWrapperView(Context context, int containerStyle) {
        super(context);
        this.containerStyle = containerStyle;
        init();
    }

    private void init() {
        setOrientation(LinearLayout.VERTICAL);
        setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        setPadding(20, 0, 0, 0);
        
//        nodeContainer = new RelativeLayout(getContext());
//        nodeContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
//        nodeContainer.setId(R.id.node_header);
//
//        ContextThemeWrapper newContext = new ContextThemeWrapper(getContext(), containerStyle);
//        nodeItemsContainer = new LinearLayout(newContext, null, containerStyle);
//        nodeItemsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
//        nodeItemsContainer.setId(R.id.node_items);
//        nodeItemsContainer.setOrientation(LinearLayout.VERTICAL);
//        nodeItemsContainer.setVisibility(View.GONE);
//
//        addView(nodeContainer);
//        addView(nodeItemsContainer);
    }


    public void insertNodeView(View nodeView) {
//        nodeContainer.addView(nodeView);
    	addView(nodeView);
    }

    public ViewGroup getNodeContainer() {
        return nodeContainer;
    }
}
